# coding=utf-8

import logging

from django.http import JsonResponse

# app_logger =  Logger.Logger.getLogger("mgr.log", toFile=True,toScreen=True,toSocket=False,level=LOG_LEVEL)
app_logger = logging.getLogger("proxy")

Error_Not_Login = JsonResponse({'retcode': 1, 'msg': '未登录', 'redirect': '/proxy/login/login.html'})
Error_Not_Admin = JsonResponse({'retcode': 1, 'msg': '非法调用', 'redirect': '/proxy/login/login.html'})


def CheckUserIsProxyForApiCaller(request):
    if not request.user.is_authenticated():
        return Error_Not_Login

    if 'ut' not in request.session:
        return Error_Not_Login

    if request.session['ut'] != 5:
        return Error_Not_Admin

    return True